package com.itetchologyandenglish.home.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itetchologyandenglish.home.enetity.Company;
import com.itetchologyandenglish.home.mapper.CompanyMapper;
import com.itetchologyandenglish.home.service.CompanyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {
    @Resource
    CompanyMapper companyMapper;

    @Override
    public PageInfo searchCompany(String companyName, String companyProject, String searchbegin, String searchend, Integer limit, Integer page,Integer isvip) {
        PageHelper.clearPage();
        PageHelper.startPage(page,limit);
        List<Company> companyList=companyMapper.getCompany(companyName,companyProject,searchbegin,searchend,isvip);
        PageInfo  pageInfo=new PageInfo(companyList);
        return pageInfo;
     }

    @Override
    public boolean deleteNormalCompany(Integer companyId) {
        return companyMapper.deleteNormalCompany(companyId)>0?true:false;
    }

    @Override
    public Company findNormaoCompanyById(Integer companyId) {
        return companyMapper.findNormaoCompanyById(companyId);
    }

    @Override
    public boolean updateNormalcompany(Company company) {
        return companyMapper.updateNormalcompany(company)>0?true:false;
    }

    @Override
    public boolean upgradetovip(Integer companyid, Date vipbegin, Date vipend) {
        return companyMapper.upgradetovip(companyid,vipbegin,vipend)>0?true:false;
    }

    @Override
    public boolean insertVipCompany(Company company) {
        return companyMapper.insertVipCompany(company)>0?true:false;
    }
    @Override
    public boolean updateVipCompany(Company company) {
        return companyMapper.updateVipCompany(company)>0?true:false;
    }

//    @Override
//    public List<Company> findVipCompanyByCompanyName(String companyName) {
//        return companyMapper.findVipCompanyByCompanyName(companyName);
//    }
@Override
    public Company findVipCompanyByCompanyName(String companyName) {
        return companyMapper.findVipCompanyByCompanyName(companyName);
    }

    @Override
    public List<Company> findVipCompanyByUserName(String userName) {
        return companyMapper.findVipCompanyByUserName(userName);
    }

}
